package com.xuanyuanxinyu.core.arouter

import android.net.Uri
import android.os.Bundle
import android.util.Log
import androidx.appcompat.app.AppCompatActivity
import com.alibaba.android.arouter.facade.Postcard
import com.alibaba.android.arouter.facade.annotation.Autowired
import com.alibaba.android.arouter.facade.annotation.Route
import com.alibaba.android.arouter.launcher.ARouter
import com.xuanyuanxinyu.core.R
import com.xuanyuanxinyu.core.arouter.IArouterConstants.KEY_AGE


@Route(path = com.xuanyuanxinyu.core.arouter.IArouterConstants.PATH_AROUTER_AUTO)
class AutowiredActivity : AppCompatActivity() {
    @JvmField
    @Autowired(name = "name")
    var name: String = ""

    @JvmField
    @Autowired(name = KEY_AGE)
    var age = 0

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_arouter)
        ARouter.getInstance().inject(this)
        Log.i("11111111", "name ==" +"      "+ name + "age ==" + age);
    }
    
    
    /**
     * 通过Uri进行跳转
     */
    fun jumpByUri() {
        val uri = Uri.parse("https://m.aliyun.com/")
        val postcard: Postcard = ARouter.getInstance()
            .build(uri)
        postcard.navigation()
    }
    
    /**
     * 通过路由路径进行跳转
     */
    fun jumpByArouterPath() {
        val postcard: Postcard = ARouter.getInstance()
            .build(com.xuanyuanxinyu.core.arouter.IArouterConstants.PATH_AROUTER_ACTIVITY)
        postcard.navigation()
        
    }
}